import { reqCategory, reqPicCategory } from '../api'
const state = {
  category: [], // 所有文章的分类
  picCategory: [],//图片的分类
}
const mutations = {
  GETCATEGORY(state, category) {
    state.category = category
  },
  GETPICCATEGORY(state, picCategory) {
    state.picCategory=picCategory
  }
}
const actions = {
  // 获取所有图片的数据
  async getCategory({ commit }) {
    let result = await reqCategory();
    if (result.code == 200) {
      commit("GETCATEGORY", result.data.data)
    }
  },
  // 获取图片的分类
  async getPicCategory({ commit }) {
    let result = await reqPicCategory()
    if (result.code == 200) {
      commit("GETPICCATEGORY", result.data.data)
    }
  }
}
const getters = {}
export default {
  state, mutations, actions, getters
}